package com.ruoyi.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.car.domain.CarMaintenanceRecordTemp;
import com.ruoyi.car.service.ICarMaintenanceRecordTempService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修保养记录中间Controller
 * 
 * @author ruoyi
 * @date 2022-12-03
 */
@RestController
@RequestMapping("/car/temp")
public class CarMaintenanceRecordTempController extends BaseController
{
    @Autowired
    private ICarMaintenanceRecordTempService carMaintenanceRecordTempService;

    /**
     * 查询维修保养记录中间列表
     */
    @PreAuthorize("@ss.hasPermi('car:temp:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarMaintenanceRecordTemp carMaintenanceRecordTemp)
    {
        startPage();
        List<CarMaintenanceRecordTemp> list = carMaintenanceRecordTempService.selectCarMaintenanceRecordTempList(carMaintenanceRecordTemp);
        return getDataTable(list);
    }

    /**
     * 导出维修保养记录中间列表
     */
    @PreAuthorize("@ss.hasPermi('car:temp:export')")
    @Log(title = "维修保养记录中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarMaintenanceRecordTemp carMaintenanceRecordTemp)
    {
        List<CarMaintenanceRecordTemp> list = carMaintenanceRecordTempService.selectCarMaintenanceRecordTempList(carMaintenanceRecordTemp);
        ExcelUtil<CarMaintenanceRecordTemp> util = new ExcelUtil<CarMaintenanceRecordTemp>(CarMaintenanceRecordTemp.class);
        util.exportExcel(response, list, "维修保养记录中间数据");
    }

    /**
     * 获取维修保养记录中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:temp:query')")
    @GetMapping(value = "/{tempId}")
    public AjaxResult getInfo(@PathVariable("tempId") Long tempId)
    {
        return success(carMaintenanceRecordTempService.selectCarMaintenanceRecordTempByTempId(tempId));
    }

    /**
     * 新增维修保养记录中间
     */
    @PreAuthorize("@ss.hasPermi('car:temp:add')")
    @Log(title = "维修保养记录中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarMaintenanceRecordTemp carMaintenanceRecordTemp)
    {
        return toAjax(carMaintenanceRecordTempService.insertCarMaintenanceRecordTemp(carMaintenanceRecordTemp));
    }

    /**
     * 修改维修保养记录中间
     */
    @PreAuthorize("@ss.hasPermi('car:temp:edit')")
    @Log(title = "维修保养记录中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarMaintenanceRecordTemp carMaintenanceRecordTemp)
    {
        return toAjax(carMaintenanceRecordTempService.updateCarMaintenanceRecordTemp(carMaintenanceRecordTemp));
    }

    /**
     * 删除维修保养记录中间
     */
    @PreAuthorize("@ss.hasPermi('car:temp:remove')")
    @Log(title = "维修保养记录中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tempIds}")
    public AjaxResult remove(@PathVariable Long[] tempIds)
    {
        return toAjax(carMaintenanceRecordTempService.deleteCarMaintenanceRecordTempByTempIds(tempIds));
    }
}
